<%
  var date = date();
%>
<div class="am-u-sm-12">
  <form class="am-form" id="list-form" action="${base}/broadband/list" method="post">
    <input type="hidden" id="keywords" name="keywords" value='${keywords!""}' />
    <table class="am-table am-table-bordered am-table-radius table-main am-padding-0">
      <tbody>
        <tr>
          <th class="am-text-middle">业务名称</th>
          <td>
            <div class="am-u-sm-10">
              <input type="text" id="name" name="name" class="am-form-field am-input-sm" value="${name!}" />
            </div>
          </td>
          <th class="am-text-middle">业务简介</th>
          <td>
            <div class="am-u-sm-10">
              <input type="text" id="business_summary" class="am-form-field am-input-sm" value="${business_summary!}"/>
            </div>
          </td>
        </tr>
        <tr>
          <th class="am-text-middle">宽带价格</th>
          <td>
            <div class="am-u-sm-10">
              <input type="text" id="price" class="am-form-field am-input-sm" value="${price!}" />
            </div>
          </td>
          <th class="am-text-middle">宽带品牌</th>
          <td>
            <div class="am-u-sm-10">
              <input type="text" id="brand" class="am-form-field am-input-sm" value="${brand!}"/>
            </div>
          </td>
        </tr>
        <tr>
          <th class="am-text-middle">所属城市</th>
          <td>
            <div class="am-u-sm-10">
              <input type="text" id="city" class="am-form-field am-input-sm" value="${city!}" />
            </div>
          </td>
          <th class="am-text-middle">计费周期</th>
          <td>
            <div class="am-u-sm-10">
              <select id="period" data-am-selected="{btnSize: 'sm'}" placeholder="所有">
                <option value="0" <%if(period! == "") {%>selected<%}%>>所有</option>
                <option value="月" <%if(period! == "月") {%>selected<%}%>>月</option>
                <option value="年" <%if(period! == "年") {%>selected<%}%>>年</option> 
              </select>
            </div>
          </td>
        </tr>
        <tr>
          <th class="am-text-middle">发布人</th>
          <td>
            <div class="am-u-sm-10">
              <input type="text" id="creator_name" class="am-form-field am-input-sm"  value="${creator_name!}"/>
            </div>
          </td>
          <th class="am-text-middle">发布人机构名称</th>
          <td>
            <div class="am-u-sm-10">
              <input type="text" id="creator_org" class="am-form-field am-input-sm" value="${creator_org!}"/>
            </div>
          </td>
        </tr>
        <tr>
          <th class="am-text-middle">宽带类型</th>
          <td>
            <div class="am-u-sm-10">
              <select name="broad_type" id="broad_type" data-am-selected="{btnSize: 'sm',btnWidth: '100%'}">
                                <option value="100" <%if(!has(broad_type)){%>
                                checked
                                <%}%>>全部</option>
                <option value="0" <%if(broad_type! == "0") {%>selected<%}%>>爱家小区</option>
                <option value="1" <%if(broad_type! == "1") {%>selected<%}%>>优家小区</option>
                <option value="2" <%if(broad_type! == "2") {%>selected<%}%>>商务动力</option> 
                <option value="3" <%if(broad_type! == "3") {%>selected<%}%>>校园套餐</option> 
              </select>
            </div>
          </td>
          <th class="am-text-middle">适用范围</th>
          <td>
            <div class="am-u-sm-10">
               <select name="business_type" id="business_type" data-am-selected="{btnSize: 'sm',btnWidth: '100%'}">
                                <option value="0" <%if(!has(business_type)){%>
                                checked
                                <%}%>>全部</option>
                <option value="1" <%if(business_type! == "1") {%>selected<%}%>>开户</option>
                <option value="2" <%if(business_type! == "2") {%>selected<%}%>>预约</option> 
                <option value="3" <%if(business_type! == "3") {%>selected<%}%>>开户和预约</option> 
              </select>
            </div>
          </td>
        </tr>
        
        <tr>
            <td colspan="4">
              <div align='right'>
                <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary" onClick="submit_btn('search');">搜索</button>
                <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary" onClick="submit_btn('export');">导出</button>
              </div>
            </td>
        </tr>
      </tbody>
    </table>
  </form>
</div>
<script type="text/javascript">
    var keywordsObj = {};
    var submit_btn = function(businessType){
      if($("#name").val())
        keywordsObj.name = $("#name").val();
      if($("#business_summary").val())
        keywordsObj.business_summary = $("#business_summary").val();
      if($("#price").val())
        keywordsObj.price = $("#price").val();
      if($("#brand").val())
        keywordsObj.brand = $("#brand").val();
      if($("#city").val())
        keywordsObj.city = $("#city").val();
      if($("#period").val() && $("#period").val() != "0")
        keywordsObj.period = $("#period").val();
      if($("#creator_name").val())
        keywordsObj.creator_name = $("#creator_name").val();
      if($("#creator_org").val())
        keywordsObj.creator_org = $("#creator_org").val();
      if(($("#broad_type").val())&&($("#broad_type").val()!="100"))
        keywordsObj.broad_type = $("#broad_type").val();
      if(($("#business_type").val())&&($("#business_type").val()!="0"))
        keywordsObj.business_type = $("#business_type").val();
      var keywords = "";
      if(!$.isEmptyObject(keywordsObj)){
        keywords = JSON.stringify(keywordsObj);
      }
      console.log("keywords = "+ keywords);
      $("#keywords").val(keywords);
      if(businessType == "search"){
         window.location.href = "${base}/broadband/list?keywords="+keywords;
      }else if(businessType == "export"){
      	window.location.href = "${base}/broadband/export?keywords="+keywords;
      }
    }
  </script>